package pojo;

import java.io.Serializable;
import java.util.Date;
import java.sql.Timestamp;

import com.alibaba.fastjson.annotation.JSONField;

import annotation.Table;
import annotation.TableColumn;

/**
* @desc：the module of table ${table_name}
* @desc for the condition of one page mamage the CRUD function of one table， 
*	you dan use the @Table and the @TableColumn annotation for rapidly coding
<#if table_remark !="">* @desc found table comment  ${table_remark},default used as the fileName of the excel file Exported</#if> 
* @author GenUI.codeGen roykingw
* @date ${gen_time}
*/
@Table(tableName = "${table_name_small}"<#if table_remark !="">,expFileName="${table_remark}"<#else>,expFileName="导出数据文件"</#if> <#if table_order_by?exists>,orderBy="${table_order_by}"</#if><#if table_order?exists>,order="${table_order}"</#if>)
public class ${pojo_name} implements Serializable{
   
    <#if COLUMNS?exists>
        <#list COLUMNS as model>
    /**
    * this method is generated by GenUI.CodeGen.enjoy coding.
    * ${model.javaName} the value of ${table_name}.${model.columnName}
    * Found comment on this column is ${model.remarks} default used as the header of this column in excel exported and the query table on page
    */
    <#if model.javaType=="Date">@JSONField(format="yyyy-MM-dd")
    <#elseif model.javaType=="Timestamp">@JSONField(format="yyyy-MM-dd hh:mm:ss")</#if>
    @TableColumn(dbColumn = "${model.columnName}",dbColumnType = "${model.columnType}"<#if model.remarks != "">,excelHeader = "${model.remarks}"</#if><#if model.isPK == "true">,isPK="true"</#if>)
    private ${model.javaType} ${model.javaName};

        </#list>
    </#if>
    
    private static final long serialVersionUID = 1L;
    
    <#if COLUMNS?exists>
        <#list COLUMNS as model>
	public ${model.javaType} ${model.getterName}() {
        return ${model.javaName};
    }
    
    public void ${model.setterName}(${model.javaType} ${model.javaName}) {
        <#if model.javaType == "String">
        this.${model.javaName} = ${model.javaName} == null ? null : ${model.javaName}.trim();
        <#else>
        this.${model.javaName} = ${model.javaName};
        </#if>
    }
        </#list>
    </#if>
    
    public String toString(){
    	StringBuilder sb = new StringBuilder();
    	sb.append("pojo.${pojo_name} ").append("[");
    	<#if COLUMNS?exists>
	        <#list COLUMNS as model>
	    sb.append(", ${model.javaName} = ").append(${model.javaName});
	        </#list>
	    </#if>
	    sb.append("]");
	    return sb.toString();
    }
    
}